import { ref } from 'vue'
export default function todoList () {
  const itemName = ref('')

  const handleAddItem = (dataSource) => {
    dataSource.push({
      name: itemName.value,
      hasDo: false
    })
    itemName.value = ''
  }

  const handleItemStatus = (index, dataSource) => {
    dataSource[index].hasDo = !dataSource[index].hasDo
  }

  const handleRemove = (index, dataSource) => {
    dataSource.splice(index, 1)
  }

  return {
    itemName,
    handleAddItem,
    handleItemStatus,
    handleRemove
  }
}